package com.yzfarm.biujoke.biujoke.ui.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.text.Html;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.yzfarm.biujoke.biujoke.R;
import com.yzfarm.biujoke.biujoke.mvp.model.bean.Contentlist;
import com.yzfarm.biujoke.biujoke.mvp.model.bean.JokeTextBean;
import com.yzfarm.biujoke.biujoke.mvp.model.datamanager.ImageLoadManager;
import com.yzfarm.biujoke.biujoke.mvp.model.datamanager.ImageLoader;
import com.yzfarm.biujoke.biujoke.mvp.view.BrowseBiuActivity;
import com.yzfarm.biujoke.biujoke.ui.viewholder.Star12ViewHolder;
import com.yzfarm.biujoke.biujoke.utils.HtmlUtil;
import com.yzfarm.biujoke.biujoke.utils.pojo.NewMeinvItem;

import java.util.List;

/**
 * Created by han on 2015/11/29.
 */
public class JokeRecyclerAdpter extends RecyclerView.Adapter<JokeRecyclerAdpter.JokeViewHolder> {

    private Context mContext;
    private List<Contentlist> mData;
    private ImageLoader imageLoader;
    public JokeRecyclerAdpter(Context context, List<Contentlist> list){
        Log.d("123","JokeRecyclerAdpter");
        mContext = context;
        mData = list;
        imageLoader = ImageLoadManager.getImagerLoader();
    }

    public void setmData(List<Contentlist> mData) {
        this.mData = mData;
    }

    @Override
    public JokeViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        Log.d("123","onCreateViewHolder ");
        JokeViewHolder holder = new JokeViewHolder(LayoutInflater.from(mContext).inflate(R.layout.joke_item,parent,false));
        return holder;
    }

    @Override
    public void onBindViewHolder(JokeViewHolder holder, int position) {
        Contentlist bean = mData.get(position);
        holder.title.setText(bean.getTitle());
        holder.content.setText(Html.fromHtml(bean.getText()));
        holder.itemView.setTag(R.integer.joke_id,position);

    }

    private View.OnClickListener cls = new View.OnClickListener() {
        @Override
        public void onClick(View v) {

        }
    };

    @Override
    public int getItemCount() {
        return mData.size();
    }

    public class JokeViewHolder extends RecyclerView.ViewHolder{

        public TextView title,content;

        public JokeViewHolder(View itemView) {
            super(itemView);
            title = (TextView) itemView.findViewById(R.id.title);
            content = (TextView) itemView.findViewById(R.id.content);
        }
    }
}
